﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHModel.Entities;
using NHibernate;

namespace NHBLL
{
    public static class OrdersService
    {

        public static IList<Orders> GetAll()
        {            
            ISession session = NHelper.GetCurrentSession();
            IQuery iq = session.CreateQuery("from Orders");
            return iq.List<Orders>();
        }

        public static Orders GetModelByOrderID(int OrderID)
        {
            ISession session = NHelper.GetCurrentSession();
            ICriteria crit = session.CreateCriteria(typeof(Orders));
            crit.Add(NHibernate.Criterion.Expression.Eq("id", OrderID));            
            Orders item = (Orders)crit.UniqueResult();
            return item;     
        }
    }
}
